package com.ssm.controller;

import com.ssm.entity.RoleResourceURL;
import com.ssm.entity.UserProfile;
import com.ssm.service.UserRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import java.util.List;
import java.util.Set;

/**
 * Created by wchen on 2017/7/15.
 */
@Controller
public class TestController {
    @Autowired
    private UserRoleService userRoleService;

    @RequestMapping(value = "/getAllRoles" , method = RequestMethod.GET)
    public String getAllRoles(){
        Set<UserProfile> allRoles = userRoleService.getAllRoles();
        return allRoles.toString();
    }

    @RequestMapping(value = "/getRoleUrl" , method = RequestMethod.GET)
    public String getRoleUrl(String role){
        List<RoleResourceURL> roleUrl = userRoleService.getAllResourceURLByRole(role);
        return roleUrl.toString();
    }
    @RequestMapping(value = "/getAll" , method = RequestMethod.GET)
    public String getAll(){
        List<List<RoleResourceURL>>  roleUrl = userRoleService.getAllResourceURLAndAllRoles();
        return roleUrl.toString();
    }




}
